<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$item=$this->plugin_setting('saleset');
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'set',
		'desc'=>'积分抵扣设置',
		'edit'=>array(
			array('type'=>'switch','name'=>'deduct_credit1','title'=>'积分抵扣','help'=>'这里是全局抵扣设置，如果具体商品也设置了，将以商品设置的为准！'),
			array('type'=>'unitstring','unit'=>'比1','name'=>'deduct_bili','title'=>'积分抵扣比例','help'=>'例如设置为10,即10积分抵1元,商品最多抵扣的数目需要在商品【营销设置】中单独设置','show'=>array('deduct_credit1'=>1)),
			array('type'=>'unitstring','unit'=>'%','name'=>'deduct_maxfeebili','title'=>'积分最大抵扣的额度比例','help'=>'默认50；积分最大抵扣的费用比例,例如50，表示最大可抵扣一半'),
			array('type'=>'switch','name'=>'deduct_credit2','title'=>'余额抵扣','help'=>'余额属于等比例抵扣'),
			array('type'=>'unitstring','unit'=>'元','name'=>'deduct_credit2max','title'=>'余额最大抵扣','help'=>'如果设置0留空，则支持全额抵扣','show'=>array('deduct_credit2'=>1)),
			array('type'=>'switch','name'=>'deduct_dispatch','title'=>'是否可以抵扣运费'),
			
		)
	);
	$return['htmls']=$htmls;	
	exi($return);
}
if($_RQ['op']=='set'){
	$post=get_postdata();
	$post['deduct_bili']=intval($post['deduct_bili']);
	$post['deduct_maxfeebili']=intval($post['deduct_maxfeebili']);
	$this->plugin_setting('saleset',$post);
	exi('设置成功');
}